package com.heima.comment.controller;


import com.heima.comment.service.ICommentService;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.comment.dtos.QueryCommentDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Xanny
 * @Data 2024/8/22 18:46
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/comment")
@Slf4j
public class CommentController {
    @Autowired
    private ICommentService commentService;

    /**
     * 保存
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentDto dto) {
        return commentService.saveComment(dto);
    }

    /**
     * 文章评论加载
     * @return
     */
    @PostMapping("/load")
    public ResponseResult loadComments(@RequestBody QueryCommentDto dto) {
        return commentService.loadComments(dto);
    }

    /**
     * 对文章评论点赞
     * @param dto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult likeComment(@RequestBody CommentDto dto) {
        return commentService.likeComment_v2(dto);
    }

}
